<?php

namespace app\modelservice;

use app\model\Member;

class MemberService
{

    public $memberModel;

    function __construct()
    {
        $this->memberModel = new Member;    
    }

    public function pageList($condition, $fields="*", $page=1, $pageSize=DEFAULT_PAGE_SIZE)
    {
        $skip = ($page-1)*$pageSize;
        return $this->memberModel->where($condition)->limit($skip, $pageSize)->select();
    }

    public function count($condition)
    {
        return $this->memberModel->where($condition)->count();
    }

    public function create($data)
    {
        return $this->memberModel->create($data);
    }

    public function update($id, $data)
    {
        $member = $this->memberModel->find($id);
        return $member->update($data);
    }

    public function delete($condtion)
    {
        return $this->memberModel->where($condtion)->delete();
    }
}